package com.momoauth.common.tps.qiniu.service;

import com.momoauth.common.tps.qiniu.utils.QiniuUploadUtil;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

public class QiniuUploadService {

    private final String domain;
    private final String accessKey;
    private final String secretKey;
    private final String bucket;

    public QiniuUploadService(String domain, String accessKey, String secretKey, String bucket) {
        this.domain = domain;
        this.accessKey = accessKey;
        this.secretKey = secretKey;
        this.bucket = bucket;
    }

    /**
     * 调用上传方法
     * @param file
     * @return
     * @throws IOException
     */
    public String uploadFile(MultipartFile file) throws IOException {
        return QiniuUploadUtil.upload(file, domain, accessKey, secretKey, bucket);
    }
}
